package hu.tortavar2.client.mvp;

import hu.tortavar2.client.ClientFactory;
import hu.tortavar2.client.activity.AddNewProductActivity;
import hu.tortavar2.client.activity.ManageSiteDataActivity;
import hu.tortavar2.client.activity.ProductDetailActivity;
import hu.tortavar2.client.activity.ProductListActivity;
import hu.tortavar2.client.activity.WelcomeActivity;
import hu.tortavar2.client.place.AddNewProductPlace;
import hu.tortavar2.client.place.ManageSiteDataPlace;
import hu.tortavar2.client.place.ProductDetailPlace;
import hu.tortavar2.client.place.ProductListPlace;
import hu.tortavar2.client.place.WelcomePlace;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class ContentActivitiMapper implements ActivityMapper {

	private  final ClientFactory clientFactory;
	
	public ContentActivitiMapper(ClientFactory clientFactory){
		this.clientFactory = clientFactory;
	}
	@Override
	public Activity getActivity(Place place) {
		if(place instanceof WelcomePlace)
			return new WelcomeActivity(clientFactory);
		if(place instanceof ProductListPlace)
			return new ProductListActivity((ProductListPlace)place, clientFactory);
		if(place instanceof AddNewProductPlace)
			return new AddNewProductActivity((AddNewProductPlace) place, clientFactory);
		if(place instanceof ManageSiteDataPlace)
			return new ManageSiteDataActivity((ManageSiteDataPlace)place, clientFactory);
		if(place instanceof ProductDetailPlace)
			return new ProductDetailActivity((ProductDetailPlace)place, clientFactory);
		return null;
	}

}
